package com.zenithmind.chat.pojo.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

@Data
@Schema(description = "AI对话消息DTO")
public class AiChatMessageDTO {
    
    @NotNull(message = "对话ID不能为空")
    @Schema(description = "对话ID")
    private String chatId;
    
    @NotBlank(message = "消息内容不能为空")
    @Schema(description = "消息内容")
    private String content;
    
    @Schema(description = "父消息ID")
    private String parentId;
    
    @Schema(description = "用户ID")
    private String userId;
    
    @Schema(description = "模型名称")
    private String modelName;
    
    @Schema(description = "模型类型(1-OpenAI,2-Ollama,3-Azure,4-Anthropic,5-自定义)")
    private Integer modelType;
    
    /**
     * 设置模型名称的同时，根据模型名称推断模型类型
     */
    public void setModelName(String modelName) {
        this.modelName = modelName;
        // 如果已设置模型类型，则不覆盖
        if (this.modelType == null && modelName != null) {
            // 根据模型名称推断类型
            if (modelName.contains("qwen") || modelName.contains("ollama")) {
                this.modelType = 2; // Ollama
            } else if (modelName.contains("gpt") || modelName.contains("text-davinci")) {
                this.modelType = 1; // OpenAI
            } else if (modelName.contains("claude")) {
                this.modelType = 4; // Anthropic
            } else if (modelName.contains("azure")) {
                this.modelType = 3; // Azure
            } else {
                this.modelType = 5; // 自定义
            }
        }
    }
} 